﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Baopx_API;

namespace A.Controller
{
    public class NewsController
    {
        public static void Insert(New @new)
        {
            A.M.d.News.InsertOnSubmit(@new);
            A.M.d.SubmitChanges();
        }

        public static void Update()
        {
            A.M.d.SubmitChanges();
        }

        public static void Delete(New @new)
        {
            A.M.d.News.DeleteOnSubmit(@new);
            A.M.d.SubmitChanges();
        }

        public static New GetElementById(int id)
        {
            return A.M.d.News.SingleOrDefault(i => i.Id == id);
        }

        public static List<New> GetAll()
        {
            return A.M.d.News.ToList();
        }
    }
}
